﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ShevaEngine.Core.Modules.Scenes;

namespace ShevaEngineTools.Editor.Lights
{
    /// <summary>
    /// Lights settings user control.
    /// </summary>
    public partial class SceneObjectsSettings : UserControl
    {
        /// <summary>Scene object selected event.</summary>
        public event OnSceneObjectSelectedCallback SceneObjectSelected;

        /// <summary>
        /// Constructor.
        /// </summary>
        public SceneObjectsSettings(List<SceneObject> sceneObjects)
        {
            this.InitializeComponent();
            this.Dock = DockStyle.Fill;

            foreach (SceneObject item in sceneObjects)
                this.ObjectsListBox.Items.Add(item);
        }

        /// <summary>
        /// ListBox 1 selected index changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ObjectsListboxSelectedIndexChanged(object sender, EventArgs e)
        {
            this.ObjectSettings.SelectedObject = this.ObjectsListBox.SelectedItem;

            if (this.SceneObjectSelected != null)
                this.SceneObjectSelected(this, (SceneObject)this.ObjectSettings.SelectedObject);
        }
    }

    /// <summary>
    /// On scene object selected callback.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public delegate void OnSceneObjectSelectedCallback(object sender, SceneObject e);
}
